#include <iostream>
/*
	++前置和后置写法有点特别
	
*/
using namespace std;
class Dog
{
public:
	Dog(int _age)
	{
		age=_age;
	}
	//重载后置的++运算
	Dog operator++(int)  //参数int主要为了区分后置++和前置++两个运算符重载的写法
	{
		Dog temp=*this; //先保存当前对象的值
		this->age+=1; //然后值+1
		return temp;
	}
	//重载前置的++运算 
	Dog operator++()
	{
		this->age+=1;
		return *this;
	}
	void show()
	{
		cout<<"age  "<<age<<endl;
	}
private:
	int age;
};
int main()
{
	Dog dog(5);
	cout<<"dog原本的年龄值是:"<<endl;
	dog.show();
	
	//dog++后置
	//Dog otherdog=dog++;     
	Dog otherdog=dog.operator++(78);
	cout<<"dog++之后"<<endl;
	otherdog.show();
	dog.show();


	//++dog前置
	//Dog dog2=++dog;     
	Dog dog2=dog.operator++();
	dog2.show();
	dog.show();
}